package com.dingwei.lesyndrome.ui.activity;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;

import com.dingwei.lesyndrome.R;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/3/6.
 */
public class WelcomeActivity extends BaseActivity {
    @Bind(R.id.start_bg)
    ImageView startBg;
    @Bind(R.id.btn_next)
    Button btnNext;
    private MyCount myCount;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
        Window window = WelcomeActivity.this.getWindow();
        window.setFlags(flag, flag);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_welcome;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        myCount = new MyCount(5000, 1000);
        myCount.start();
    }


    @Override
    protected void onResume() {
        super.onResume();
    }

    @OnClick({R.id.start_bg, R.id.btn_next})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.start_bg:
                break;
            case R.id.btn_next:
                intent.setClass(WelcomeActivity.this, MainActivity.class);
                startActivity(intent);
                myCount.cancel();
                finish();
                break;
        }
    }


    /**
     * 倒计时
     */
    public class MyCount extends CountDownTimer {

        public MyCount(long millisInFuture, long countDownInterval) {
            super(millisInFuture, countDownInterval);
        }

        @Override
        public void onFinish() {
            intent.setClass(WelcomeActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }

        @Override
        public void onTick(long millisUntilFinished) {
            btnNext.setText(millisUntilFinished / 1000 + " 跳过");
        }

    }
}
